<!-- 编辑弹窗 -->
<template>
  <!-- 高级弹窗modal -->
  <ele-modal
    form
    :width="800"
    v-model="visible"
    :title="isInfo ? '数据变更日志' : isUpdate ? '修改' : '添加'"
    align-center
    @open="handleOpen"
  >
<!-- 表格 -->
      <ele-pro-table
        sticky
        ref="tableRef"
        row-key="deptId"
        :columns="columns"
        v-model:selections="selections"
        :datasource="datasource"
        :show-overflow-tooltip="true"
        highlight-current-row
        :pagination="true"
        cache-key="systemDeptTable"
      >
      </ele-pro-table>
    <template #footer>
      <el-button @click="handleCancel">取消</el-button>
    </template>
  </ele-modal>
</template>

<script setup>
  import { ref, reactive, nextTick } from 'vue';
  import { EleMessage, emailReg, phoneReg } from 'ele-admin-plus/es';
  import { useFormData } from '@/utils/use-form-data';
  import { addDept, updateDept } from '@/api/system/dept';
  import { Plus, UserFilled } from '@element-plus/icons-vue';
  const props = defineProps({
    /** 修改回显的数据 */
    data: Object,
    /** 上级台账id */
    parentId: Number,
    isInfo: Boolean
  });
/** 表格实例 */
  const tableRef = ref(null);

  /** 表格列配置 */
  const columns = ref([
    // {
    //   type: 'selection',
    //   columnKey: 'selection',
    //   width: 50,
    //   align: 'center',
    //   fixed: 'left'
    // },
    {
      type: 'index',
      label: '序号',
      columnKey: 'index',
      align: 'center',
      fixed: 'left',
      width: 100
    },
    {
      prop: '巡检项目名称',
      label: '巡检对象',
      align: 'center'
    },
    {
      prop: 'diyNum',
      label: '识别结果',
      align: 'center'
    },
    {
      prop: 'valueType',
      label: '修改前(值)',
      align: 'center'
    },
    {
      prop: 'valueType',
      label: '修改后(值)',
      align: 'center'
    },
    {
      prop: 'value',
      label: '数据变更时间',
      align: 'center'
    }
   
   
  ]);
  /** 弹窗是否打开 */
  const visible = defineModel({ type: Boolean });
  /** 关闭弹窗 */
  const handleCancel = () => {
    visible.value = false;
  };

  /** 弹窗打开事件 */
  const handleOpen = () => {
    if (props.data) {
      assignFields({
        ...props.data,
        parentId: props.data.parentId || void 0
      });
      isUpdate.value = true;
    } else {
      resetFields();
      form.parentId = props.parentId;
      isUpdate.value = false;
    }
    nextTick(() => {
      nextTick(() => {
        formRef.value?.clearValidate?.();
      });
    });
  };
</script>
